<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="se" uri="http://zc.security/acl"%> 
<div  class="easyui-layout" style="width:100%;height:100%;" fit="true">
	<div data-options="region:'north',title:'支付对账',split:true" style="height:70px;background-color:#e6edfd;">
    	<form action="" id="searchForm" name="searchForm">
    	<table class="screen">
			<tr>
				<td class="screen-n"><span>订单编号</span></td>
				<td class="screen-n">
					<input type="text" id="orderCode" class="screen-input" onkeydown="pms.kd13('initOrders')">
				</td>
				<td class="screen-n"><span>采购商编号</span></td>
				<td class="screen-n">
					<input type="text" id="buyerCode" class="screen-input"  onkeydown="pms.kd13('initOrders')">
				</td>
				<td class="screen-n"><span>订单状态</span></td>
				<td class="screen-n">
					<select id="status">
						<option value="">-全部-</option>
						<option value="14">-已审核-</option>
						<option value="20">-已支付-</option>
					</select>
				</td>
				<td class="screen-n"><span>订单时间</span></td>
				<td class="screen-n">
					<input type="text" id="startDate" class="screen-input easyui-datebox" onkeydown="pms.kd13('initOrders')">
				</td>
				<td class="screen-n"><span>至</span></td>
				<td class="screen-n">
					<input type="text" id="endDate" class="screen-input easyui-datebox" onkeydown="pms.kd13('initOrders')">
				</td>
				<td class="screen-n">
					<input type="button" class="button" value="查询" onclick="initOrders()">
					<input type="button" class="button" value="重置" onclick="pms.resetForm('searchForm')" >
				    <input type="button" class="button" value="导出" onclick="loadExecl('initStoreOutCheckTableExcel')" >
				</td>
			</tr>
		</table>
		</form>
    </div>
    
    
    <div data-options="region:'center',split:true" style="width: 100%;height: 100%">
		<table id="tableGrid"></table>
	</div>
 
 
</div> 

<script>

var ordersTable;
$(function(){
	initOrders();
});
function getParams(){
	var queryParamss = {
			"isOrderCheck":'1',
			 "orderCode":$("#orderCode").val(),
			 "status":$("#status").val(),
			 "startDate":$("#startDate").datebox("getValue"),
			 "endDate":$("#endDate").datebox("getValue"),
			 "buyerCode":$("#buyerCode").val()
	    };
    return queryParamss;
}
function initOrders(){
	ordersTable = $('#tableGrid').pDataGrid({
		 columns:[[
		           
	              {field:'createDate',title:'下单时间',align:'center'},
	              {field:'orderCode',title:'订单编号',align:'center'},
	              {field:'strStatus',title:'订单状态',align:'center'},
	              {field:'buyerName',title:'采购商名称',align:'center'},
	              {field:'totalMoney',title:'下单金额',align:'center'},
	              {field:'confirmMoney',title:'确认金额(刨去缺货)',align:'center'},
	              {field:'totalIntegral',title:'获得积分',align:'center'},
	              {field:'paymentFrom',title:'支付来源',align:'center'},
	              {field:'paymentMedthod',title:'支付方式',align:'center'},
	              {field:'feeDate',title:'付款时间',align:'center'},
	              {field:'feeAmount',title:'付款金额',align:'center'},
	              {field:'tranSerialNo',title:'支付流水',align:'center'},
	              {field:'dealFlag',title:'处理标志',align:'center',formatter:function(value){
						if(value=="1"){
							return '银行回调';
						}else if(value=="10"){
							return '手动处理';
						}else{
							return '';
						}
		           }}
	              <se:hasPermissions actCode="MAINTAIN" >
	              ,
	              {field:'action',title:'操作',align:'center',formatter:function(value,row){
	            	  var str='';
			          if(row.status >=14 && 20>row.status){
			        	 str+='<img class="iconImg ext-icon-shield" title="对账" onclick="changeOrderStatus(\''+row.orderCode+'\');"/>&nbsp;';
			          }
					  return str;
		          }}
	              </se:hasPermissions>
	             
	          ]],
		    url:'<c:url value="/ordercheck/managerSearchOrder.do"/>',  
		    pagination:true,
		    pageSize:30,
		    fitColumns:true,
		    queryParams:getParams(),
		    completeCallback:function(data){
				if(data.resultCode == "100"){
					alertError(data.errorMsg);
				} 
			},
			onDblClickRow:function(index,row){
				openOrderDetailWindow(row.orderCode);
			},
			onLoadSuccess : function(data) {
				var panel = $(this).datagrid('getPanel');
				var tr = panel.find('div.datagrid-body tr');
				tr.each(function() {
					var td = $(this).children('td[field="buyerName"]');
					td.children("div").css({
						"text-align" : "left"
					});
				});
			}
	}); 
	
}


//订单明细
function openOrderDetailWindow(code){
	var param = {"orderCode":""+code+""};
	$.pmsDialog({
		id:"win_order_detail",
		title:'订单号：'+code+" 明细",
		method:'post',
		href:'<c:url value="/views/jsp/trade/order/orderdetail_s.jsp"/>',
		width:900,
		height:400,
		params:param,
		isIf:'true'
	});
}

//状态模拟
function changeOrderStatus(code,status){
	var param = {"orderCode":""+code+""};
	$.pmsDialog({
		id:"win_order_status",
		title:'订单号：'+code+" 状态模拟",
		method:'post',
		href:'<c:url value="/views/jsp/trade/order/order_status_s.jsp"/>',
		width:500,
		height:300,
		params:param,
		isIf:'true'
	});
}
//导出
function initStoreOutCheckTableExcel(){
 	loadExcelCallBack('<c:url value="/ordercheck/searchPageEmSOrderCheckExcel.do"/>',getParams());
} 

</script>
